1. Field of Invention
The invention relates to a buffer and, in particular, to a buffer control method and a device thereof.
2. Related Art
A buffer is widely used in the modern computer system for temporarily storing packets. A packet is mainly divided into a header and a data. The header contains a write command or a read response command of the following data. Usually, the length of the header is 4 bytes (1DW) or 8 bytes (1QW), and the length of the data is from 4 bytes (1DW) to 64 bytes (8QW).
FIG. 1 is a schematic illustration showing a buffer for storing packets. The buffer 120 includes a command queue region 121 and a data region 122. The command queue region 121 and the data region 122 are orderly arranged.
In FIG. 1, assume the total capacity of command queue region 121 is 4QW, and the command queue region 121 has four spaces #11˜#14 (i.e. each space is 1QW) for respectively storing one command. Furthermore, the total capacity of data region 122 is 32QW, and the data region 122 has four spaces #21˜#24 (i.e. each space is 8QW) for respectively storing one data. Each space #11˜#14 of the command queue region 121 is corresponding to one of the spaces #21˜#24 of the data region 122. For example, while four packets PAK1˜PAK4 (i.e. each packet has 2QW data length) are stored in the buffer 120. Therefore, the commands of the packets PAK1˜PAK4 are sequentially stored in the spaces #11˜#14 of the command queue region 121 and the corresponding data of the packets PAK1˜PAK4 are stored in the spaces #21˜#24 of the data region 122.
As the description above, it's noticed that, each packet is stored in one space of the command queue region 121 and the data region 122. Therefore, each space #21˜#24 of the data region has 6QW which is not used, resulting in the inefficiency usage of the buffer 120.